package com.example.springboot.config.elasticsearch;

import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.RestClients;
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;

/**
 * elasticsearch的配置
 * @Author:ChenZhangKun
 * @Date: 2020/10/26 22:10
 */
@Configuration
public class MyElasticsearchConfig extends AbstractElasticsearchConfiguration {
    /**
     * springboot官方推荐配置
     * @return
     */
    @Override
    @Bean
    public RestHighLevelClient elasticsearchClient() {
        final ClientConfiguration build = ClientConfiguration.builder()
                .connectedTo("192.168.25.134:9200")
                .build();
        return RestClients.create(build).rest();
    }
}
